import request from './network'

export function getGoodNum(data){
  return request({
    // 创建订单地址
    url:'/my/orders/create',
    method:'post',
    data:data.data
  })
}
export function AdvancePayment(data){
  return request({
    // 与支付地址
    url:'/my/orders/req_unifiedorder',
    method:'post',
    data:data.data
  })
}
/**
 * promise 形式的微信支付
 * @param {object} data 支付所必要的参数 
 */
export function requestPayment(data){
  return new Promise((resolve,reject)=>{
    wx.requestPayment({
      nonceStr: data.nonceStr,
      package: data.package,
      paySign: data.paySign,
      timeStamp: data.timeStamp,
      success:(result)=>{
        resolve(result)
      },
      fail:(err)=>{
        reject(err)
      }
    })
  })
}
export function chkOrder(data){
  return request({
    // 查询订单状态
    url:'/my/orders/chkOrder',
    method:'post',
    data:data.data
  })
}